package com.zut.base.common.util;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author zhang
 * @date 2020/11/11 16:12
 */
@Component
public class DataAutoFill implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject meta) {
        this.strictInsertFill(meta, "createtime", Date.class,new Date());
        this.setFieldValByName("head", "/static/img/head.b818068.png", meta);
        this.setFieldValByName("updatetime", new Date(), meta);

    }

    @Override
    public void updateFill(MetaObject meta) {
        this.strictInsertFill(meta, "updatetime", Date.class,new Date());
    }

}
